package com.lhl.shiro.shiroconfig;

import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.credential.CredentialsMatcher;
import org.springframework.beans.factory.annotation.Autowired;


/**
 * @author LHL
 * @date 2018/1/8
 */

public class StatelessCredentialMatcher implements CredentialsMatcher {

    @Autowired
    private SystemCacheManager systemCacheManager;

    @Autowired
    public void setSystemCacheManager(SystemCacheManager systemCacheManager) {
        this.systemCacheManager = systemCacheManager;
    }

    @Override
    public boolean doCredentialsMatch(AuthenticationToken authenticationToken, AuthenticationInfo authenticationInfo) {
            return systemCacheManager.validateToken((StatelessToken)authenticationToken);
    }
}
